package org.nf.ajax.servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/index.do")
public class HtmlServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        String name = req.getParameter("name");
        String pass = req.getParameter("pass");
        String msg = "错误的账号或密码";
        if(name.equals("admin") && pass.equals("1234")) {
            msg = "yes";
        }

        PrintWriter out = resp.getWriter();

        out.write(msg);
        out.flush();
        out.close();
    }
}
